package com.d3works.apps.base.service.config;

import com.d3works.apps.base.db.Company;
import com.d3works.apps.base.db.Currency;
import com.d3works.apps.base.exceptions.BaseExceptionMessage;
import com.d3works.exception.D3worksException;
import com.d3works.exception.db.repo.TraceBackRepository;
import com.d3works.i18n.I18n;

public class CompanyConfigService {

  public Currency getCompanyCurrency(Company company) throws D3worksException {

    if (company.getCurrency() == null) {
      throw new D3worksException(
          company,
          TraceBackRepository.CATEGORY_CONFIGURATION_ERROR,
          I18n.get(BaseExceptionMessage.COMPANY_CURRENCY),
          I18n.get(BaseExceptionMessage.EXCEPTION),
          company.getName());
    }

    return company.getCurrency();
  }
}
